﻿Imports System.Data.Entity.Validation
Imports System
Imports System.Security.Claims
Imports System.Web.UI
Imports System.Data.OleDb


' --Smart Money $aver Project for University of Herts--%>
''--Version 1--%>
'--Update 1 -  20th Feb 2014 - Gene Added information / fields--%>
'--Update 2 -  20th June 2014 - Gene Added information / Tag Field fields


Public Class AddComment
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Try

            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString001").ConnectionString)
            Dim SqlString As String = "SELECT * FROM sms_register  where username=@username"

            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
            cmd.CommandType = CommandType.Text
            cmd.Parameters.AddWithValue("@username", Session("UserName"))
            oleDbConn.Open()
            Dim sda As OleDbDataAdapter = New OleDbDataAdapter(cmd)
            Dim ds As DataSet = New DataSet()
            sda.Fill(ds)


            Dim oleDbConn1 As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString001").ConnectionString)
            Dim SqlString1 As String = "insert into sms_comments (Comment,Author,Title,sms_moneydata_fkId,rating,sms_username_fkid,tag)values(@comment, @author, @title, @moneytype,  @f5, @username,@tag) "

            Dim cmd1 As OleDbCommand = New OleDbCommand(SqlString1, oleDbConn1)


            cmd1.CommandType = CommandType.Text

            cmd1.Parameters.AddWithValue("@comment", txt_comment.Text)
            cmd1.Parameters.AddWithValue("@author", txt_author.Text)
            cmd1.Parameters.AddWithValue("@title", txt_title.Text)
            cmd1.Parameters.AddWithValue("@moneytype", ddl_moneydata.SelectedValue)
            ' Added field ddl-tagname 
            cmd1.Parameters.AddWithValue("@tag", ddl_tagname.Text)

            If RadioButton1.Checked = True Then
                cmd1.Parameters.AddWithValue("@f5", 1)
            ElseIf RadioButton2.Checked = True Then
                cmd1.Parameters.AddWithValue("@f5", 2)
            ElseIf RadioButton3.Checked = True Then
                cmd1.Parameters.AddWithValue("@f5", 3)
            ElseIf RadioButton4.Checked = True Then
                cmd1.Parameters.AddWithValue("@f5", 4)
            Else
                cmd1.Parameters.AddWithValue("@f5", 5)

            End If
            cmd1.Parameters.AddWithValue("@username", ds.Tables(0).Rows(0)("ID").ToString())
            oleDbConn1.Open()
            cmd1.ExecuteNonQuery()


            ScriptManager.RegisterClientScriptBlock( _
              Me, _
              GetType(Page), _
              "script", _
              "returnempcode();", _
              True)


        Catch ex As DbEntityValidationException

        End Try


    End Sub

    '<System.Web.Services.WebMethod>
    'Private Sub Disable(value As String, url As String)

    'End Sub

    Protected Sub ddl_tagname_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddl_tagname.SelectedIndexChanged

    End Sub
End Class